import { Controller, Post, Body, HttpCode } from '@nestjs/common';
import { WechatService } from './wechat.service';
import { ApiTags } from '@nestjs/swagger';

@ApiTags('小程序模块')
@Controller('wechat')
export class WechatController {
  constructor(private readonly wechatService: WechatService) {}

  @Post('login')
  @HttpCode(200)
  async onLogin(@Body('code') js_code: string) {
    const token = await this.wechatService.genToken(js_code);
    return {
      code: 200,
      msg: 'ok',
      data: {
        token,
      },
    };
  }
}
